function [f, prob, df1, df2] = f_test(x, y)
% f_test regarding equal variances of two groups
% from Press et al., p 619
% coded 12/2/98 P. Manis
%
[mean_x, var_x] = mean_var(x);
[mean_y, var_y] = mean_var(y);

if(var_x > var_y)
   f = var_x/var_y;
   df1=length(x)-1;
   df2=length(y)-1;
else
   f = var_y/var_x;
   df1 = length(y)-1;
   df2 = length(x)-1;
end
prob = 2.0*beta_i(0.5*df2, 0.5*df1, df2/(df2+df1*f));
if(prob > 1) prob = 2 - prob;
end
return;
